

package com.yungu.swift.report.controller;

import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.admin.AdminReportParam;
import com.yungu.swift.report.entity.ReportDriverRegisterDay;
import com.yungu.swift.report.service.DriverRegisterDayService;
import com.yungu.swift.report.utils.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author Zerrion
 * @version 1.0
 * @description 司机注册量控制器
 * @date 2018/6/4 15:27
 */
@Slf4j
@RestController
@Api(value = "司机注册数量统计", tags = "司机注册数量统计")
public class DriverRegisterDayCtrl {
    @Autowired
    private DriverRegisterDayService driverRegisterDayService;

    @PostMapping("/report/driverRegister/queryPage")
    @ApiOperation(value = "司机注册数量统计数据", httpMethod = "POST")
    public ResponseData<Map<String, Object>> queryPageIndex(@RequestBody AdminReportParam reportParam) {
        return driverRegisterDayService.queryPage(reportParam);
    }

    @PostMapping("/report/driverRegister/export")
    @ApiOperation(value = "司机注册数量统计数据导出", httpMethod = "POST")
    public void export(@RequestBody AdminReportParam reportParam, HttpServletResponse response) throws Exception {
        List<ReportDriverRegisterDay> list = this.driverRegisterDayService.list(reportParam).getData();
        if (CollectionUtils.isEmpty(list)) {
            log.warn("{}报表,没有统计数据可导出", "司机注册");

        }
        ExcelUtil.download(reportParam, response, list, ReportDriverRegisterDay.class, "/template/driver_register_report.xlsx", "司机注册");
    }
}
